package com.ebc.eservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ebc.eservice.mapper.CompanyMapper;
import com.ebc.eservice.mapper.InteractClientMapper;
import com.ebc.eservice.pojo.EbcCompany;
import com.ebc.eservice.pojo.EbcUser;
import com.ebc.eservice.pojo.EbcUserRole;
import com.ebc.eservice.service.EbcClientService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.vo.client.ClientListRespVo;
import com.ebc.eservice.vo.client.ClientQueryReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Joey
 * @Description: 客户 & 业务
 * @date:2022/10/5 11:32
 */
@Service
public class ClientImp implements EbcClientService {

    @Autowired
    private InteractClientMapper interactClientMapper;
    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public JsonResult getClientList(Integer companyId) {
        EbcCompany company = companyMapper.selectById(companyId);
        if(company!=null){
            List<ClientListRespVo> clientList = interactClientMapper.getAdminClientList(companyId);
            return JsonResult.success(clientList);
        }else{
            return JsonResult.fail("获取列表数据异常,请重新输入");
        }
    }

    //多条件查询
    @Override
    public JsonResult queryClient(ClientQueryReqVo reqVo) {
        EbcCompany company = companyMapper.selectById(reqVo.getCompanyId());
        if(company!=null){
            List<ClientListRespVo> respVos = interactClientMapper.queryClientInfo(
                            reqVo.getCompanyId(),
                            reqVo.getClientId(),
                            reqVo.getStaffId(),
                            reqVo.getClientName());
            return JsonResult.success(respVos);
        }else{
            return JsonResult.fail("查询数据异常,请重新输入");
        }
    }
}
